package com.itheima.controller.backend;

import com.itheima.common.entity.PageResult;
import com.itheima.common.entity.QueryPageBean;
import com.itheima.common.entity.Result;
import com.itheima.pojo.Order;
import com.itheima.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/order")
@Api(tags = "预约管理")
@Slf4j
public class OrderController {
    @Autowired
    private OrderService orderService;

    /**
     * 分页查询预约
     * @param queryPageBean
     * @return
     */
    @PostMapping("findPage")
    @ApiOperation("分页查询预约")
    public PageResult findPage(@RequestBody QueryPageBean queryPageBean){

        log.info("分页查询预约：{}", queryPageBean);
        PageResult pageResult = orderService.findPage(queryPageBean);
        return pageResult;
    }

    /**
     * 修改状态
     * @param order
     * @return
     */
    @PostMapping("/update")
    @ApiOperation("修改状态")
    public Result update(@RequestBody Order order){
        log.info("修改状态：{}", order);
        orderService.update(order);
        return new Result(true,"修改状态成功");

    }
}
